home *** CD-ROM | disk | FTP | other *** search
- PAGE 60,132
- TITLE Serial interface
- ;--------------------------------------------------------------------------;
- ; ;
- ; Version 3.5 <== Also in message at end of this file ;
- ; Date: February 17th, 1991 <== Ditto! ;
- ; ;
- ; Communications BIOS routines: ;
- ; ;
- ; 1) These replace the standard BIOS routine for interrupt ;
- ; handling at high speed. ;
- ; ;
- ; 2) They extend things from character orientation to line ;
- ; orientation to faciliate packets ;
- ; ;
- ; 3) They support chips other than the standard IBM 8250 type. ;
- ; ;
- ; Currently supported (but maybe not in the version you are looking at) ;
- ; ;
- ; a. IBM standard ASYNC card using the 8250. This also maps ;
- ; the AT standard serial port. ;
- ; b. The PC-100 Paccomm card containing an Zilog 8530 or equivalent ;
- ; with an onboard AMD 7910 modem. Only supported in the HDLC ;
- ; mode. ;
- ; c. QUADRAM's QUADPORT card ;
- ; d. A card contanting up to 4 ASNYC ports using standard 8250s ;
- ; with the interrupts multiplexed. ;
- ; e. 16550 chips ;
- ; ;
- ; Copyright 1983 by William E. Westfield. All rights reserved. ;
- ; Copyright 1986, 1987, 1988, 1989, 1990, 1991 by H. Roy Engehausen. ;
- ; All rights reserved. ;
- ; ;
- ; This software may be freely distributed and used, but it may not ;
- ; under any circumstances be sold by anyone other than the author. ;
- ; It may be distributed by a commercial company as long as it is ;
- ; for no cost. ;
- ; ;
- ; Change History ;
- ; 12/24/86 -- Changed vector swapping to use DOS calls ;
- ; 1/10/87 -- Transmit buffering ;
- ; 1/11/87 -- Resident monitor ;
- ; 2/01/87 -- QUADRAM card ;
- ; 2/15/87 -- 4 async port card support ;
- ; 9/01/87 -- Added 8530 support ;
- ; 5/01/88 -- Increased capability for ports ;
- ; 7/01/88 -- Turbo V4. New display format. Options. ;
- ; 8/01/88 -- AT support ;
- ; 10/07/89 -- Correct block write code ;
- ; 10/14/90 -- 16550 support ;
- ; 2/16/91 -- DV support ;
- ; ;
- ;--------------------------------------------------------------------------;
-
- ;==========================================================================;
- ; System constants ;
- ;==========================================================================;
-
- coms_to_build EQU 12 ; Number of com blocks (max)
-
- ; WARNING WARNING WARNING
-
- ; You must have at least three buffers and the minimum size is 512.
- ; This is because the initialization code is located in the place where
- ; the buffers get built during initialization. In other words, the
- ; init buffer stuff will clobber the code. If you want to change
- ; those minimums you may have to rearrange things in the init area
-
- buffers_to_build EQU 30 ; Number of buffers!
- buffer_size EQU 512 ; Bytes in each buffer
- buffer_size_para EQU buffer_size/16 ; Paragraphs in each buffer
-
- ;==========================================================================;
- ; Code generation switches -- To save storage you can select/deselect ;
- ; the code you need do minimize generating support for hardware ;
- ; you dont have or use... ;
- ; ;
- ; Prereqs... ;
- ; 8250x requires 8250 ;
- ; qrqp requires 8250 ;
- ; 4apc requires 8250 ;
- ; fifo requires 8250 ;
- ;==========================================================================;
-
- present_8250 EQU 1 ; 8250 code generation desired
- present_8250x EQU 1 ; 8250 extended code generation desired
- present_8251 EQU 0 ; 8251 code generation not desired
- present_8530 EQU 0 ; 8530 HDLC code generation not desired
- present_qrqp EQU 1 ; Quadram Quadport
- present_4apc EQU 1 ; 4 Async port card
- present_fifo EQU 1 ; 16550 FIFO support
- present_dv EQU 1 ; Desqview support
-
- ;==========================================================================;
- ; Vector numbers to use ;
- ;==========================================================================;
-
- dos_terminate_no EQU 20H ; DOS terminate interrupt
- dos_vector_no EQU 21H ; DOS main service interrupt
- dos_tsr_no EQU 27H ; DOS terminate but stay resident
-
- rs232_vector_no EQU 14H ; RS232 service interrupt
- timer_vector_no EQU 1CH ; Timer tick interrupt
-
- ;--------------------------------------------------------------------------;
- ; DOS subfunctions ;
- ;--------------------------------------------------------------------------;
-
- dos_write_line EQU 09H ; Write line to output
- dos_set_vector EQU 25H ; Set vector
- dos_get_vector EQU 35H ; Get vector
- dos_free_mem EQU 49H ; Free memory
-
- ;==========================================================================;
- ; Set up the works ;
- ;==========================================================================;
-
- everything SEGMENT PUBLIC
- ASSUME CS: everything ; These assumptions are for the
- ASSUME DS: NOTHING ; assembler's benefit. The code
- ASSUME ES: NOTHING ; jerks things around as it pleases
- ASSUME SS: NOTHING ;
-
- ;--------------------------------------------------------------------------;
- ; Copy right statements -- You must leave these in!!!! ;
- ; The symbols marker and marklen are used to search for other copies ;
- ; of this program ;
- ;--------------------------------------------------------------------------;
-
- DB 'Copyright 1983 by William E. Westfield. All rights reserved' ;
- DB 'Copyright 1986, 1987, 1988, 1989, 1990, 1991 by H. Roy Engehausen.' ;
- DB 'All rights reserved.' ;
-
- ;--------------------------------------------------------------------------;
- ; Initialize the desqview stuff ;
- ;--------------------------------------------------------------------------;
-
- IF present_dv
-
- dv_cnt = 0
- .LALL
- dv_hook MACRO NUM
- dv_hook&num LABEL BYTE
- ENDM
-
- ENDIF
-
- ;--------------------------------------------------------------------------;
- ; The DOS PSP -- Loaded by COMMAND.COM just before it gives us control ;
- ;--------------------------------------------------------------------------;
-
- ORG 2CH
- psp_environ_ptr DW ? ; Segment address of environment
-
- ORG 80H
- psp_parm_len DB ? ; Length of input parameter
- psp_parm DB ? ; Input parameter from here to 0FFH
- ; inclusive
-
- ;--------------------------------------------------------------------------;
- ; BIOS Vector -- These are not really here but allow us to play games ;
- ; to address low storage ;
- ;--------------------------------------------------------------------------;
-
- ORG timer_vector_no*4 ; Timer pop
- timer_vector DW ? ;
- DW ? ;
-
- ORG rs232_vector_no*4 ; Software interrupt vector
- rs232_vector DW ? ; to BIOS
- DW ? ;
-
- ORG 0400H ; BIOS COMx addresses
- rs232_bios_address DW ? ;
- DW ? ;
- DW ? ;
- DW ? ;
- rs232_bios_max EQU 4 ; Maximum number of com ports for that
- ; can have addresses here
-
- ;--------------------------------------------------------------------------;
- ; Buffer contents -- These are not really here but allow us to play games ;
- ; when addressing the buffers via ES. These may not be used by all the ;
- ; routines in this program. ;
- ; ;
- ; The free buffer list is chained together using the buffer_next variable ;
- ; ;
- ; The 8250 IBM ASYNC card uses its buffer in a ring fashion. Only ;
- ; 1 buffer is used for receive and another for transmit. Data is ;
- ; placed in the buffer and removed in a ring fashion. Since there ;
- ; are no chains etc, for the 8250, those service/interrupt routines ;
- ; use the whole buffer area. ;
- ; ;
- ; The 8530 has two chains: Transmit buffers are serially chained using ;
- ; the current one as the head; Receive buffers are also serially ;
- ; chained using the current one as the head. These are in reverse order, ;
- ; however, with the last one in the chain being the oldest. ;
- ; ;
- ;--------------------------------------------------------------------------;
-
- ORG 0
- buffer_dat: ; Buffer data starts here
-
- ORG buffer_size-8 ; Last eight bytes of the buffer
- buffer_siz2 EQU $-buffer_dat ;
- buffer_dl DW ? ; Number of bytes in this buffer
- buffer_st1 DB ? ; Status byte 1 for this buffer
- buffer_st1_ddb EQU 10000000B ; Don't discard buffer on xmit
- buffer_st1_xmt EQU 01000000B ; Buffer transmitted
- buffer_st2 DB ? ; Status byte 2 for this buffer
- buffer_ufld DW ? ; User field -- For application's use
- buffer_next DW ? ; Pointer to next buffer in the chain
-
- ; we should now be at the buffer size
-
- ;==========================================================================;
- ; Control block layout for each port -- Just labels to provide a structure ;
- ;==========================================================================;
-
- ORG 0
- INCLUDE MBBCOM.ASM ; Control block layout file
-
- ;==========================================================================;
- ; Program start ;
- ;==========================================================================;
-
- ORG 100H
- dos_start: JMP start ; Entry point
-
- ;==========================================================================;
- ; Configuration information ;
- ;==========================================================================;
-
- buffer_count DB buffers_to_build ; Number of buffers!
- DB coms_to_build ; Number of com ports (max)
- DB com_size ; Size of one comport
-
- com_start:
-
- INCLUDE MBCNF.ASM; ; Configuration file
-
- ORG com_start+coms_to_build*com_size
- ORG $+coms_to_build*tie_size
-
- ;==========================================================================;
- ; IBM PC (or clone) hardware constants ;
- ;==========================================================================;
-
- pic_cmd_port EQU 020H ; 8259 interrupt controller command address
- pic_mask_port EQU 021H ; 8259 interrupt controller mask address
-
- pic_clear EQU 020H ; Non-specific interrupt clear
-
- irq_offset EQU 008H ; Offset from IRQ number to vector
-
- ;==========================================================================;
- ; IBM AT (or clone) hardware constants ;
- ;==========================================================================;
-
- pic2_cmd_port EQU 0A0H ; 8259 interrupt controller command address
- pic2_mask_port EQU 0A1H ; 8259 interrupt controller mask address
-
- irq2_offset EQU 070H ; Offset from IRQ number to vector
-
- ;==========================================================================;
- ; Chip control constants ;
- ;==========================================================================;
-
-
- IF present_8250
- INCLUDE 8250CON.ASM; ; 8250 hardware constants
- ENDIF
-
- IF present_8530
- INCLUDE 8530CON.ASM; ; 8530 hardware constants
- ENDIF
-
- INCLUDE KISS.ASM; ; KISS mode constants
-
- IF present_qrqp OR present_4apc
- INCLUDE QRQPCON.ASM; ; QuadRam Quadport hardware constants
- ENDIF
-
- ;==========================================================================;
- ; Static variables ;
- ;==========================================================================;
-
- old_bios_vector DW ? ; Save previous bios vector
- DW ? ; 2 words for each
-
- old_interrupt_vec_off DW ? ; Previous hardware interrupt vectors -- offset
- ORG old_interrupt_vec_off+coms_to_build*com_size ;
- old_interrupt_vec_seg DW ? ; Previous hardware interrupt vectors -- segment
- ORG old_interrupt_vec_seg+coms_to_build*com_size ;
-
- interrupt_vector LABEL WORD ; List of interrupt handlers. As they
- DW OFFSET serint_1 ; are used, the corresponding com block
- DW OFFSET serint_2 ; address is substituted
- DW OFFSET serint_3 ;
- DW OFFSET serint_4 ;
- DW OFFSET serint_5 ;
- DW OFFSET serint_6 ;
-
- free_buffer_head DW ? ; Buffer segment at head of chain
- pool_start DW ? ; Buffer segment for pool start
-
- timer_old DW 0 ; Old timer interrupt
- DW 0 ; Need two words
- ; Zero = not valid
-
- timer_counter DB 0 ; Timer counter
-
- ;--------------------------------------------------------------------------;
- ; Local variables for QUADRAM QUADPORT or 4 async port card interrupt ;
- ; handler.. The interrupt handler runs disabled so we don't need ;
- ; seperate copies of the variables for each port/card. ;
- ;--------------------------------------------------------------------------;
-
- IF present_qrqp OR present_4apc
-
- serint_4apc_switch DB ? ; Switch to show interrupt handled
-
- qrqp_save_mir DB ? ; Master interrupt register save
- qrqp_tie_pointer DW ? ; Pointer to tie pointer to service next
-
- qrqp_int_map LABEL BYTE ; Interrupt settings for board
- DB 0 ; IRQ-0
- DB 0 ; IRQ-1
- DB 1 ; IRQ-2
- DB 1 ; IRQ-3
- DB 2 ; IRQ-4
- DB 2 ; IRQ-5
- DB 0 ; IRQ-6
- DB 0 ; IRQ-7
- DB 0 ; IRQ-8
- DB 0 ; IRQ-9
- DB 1 ; IRQ-A
- DB 1 ; IRQ-B
- DB 2 ; IRQ-C
- DB 2 ; IRQ-D
- DB 0 ; IRQ-E
- DB 0 ; IRQ-F
-
- ENDIF
-
- ;--------------------------------------------------------------------------;
- ; The symbols marker and marklen are used to search for other copies ;
- ; of this program ;
- ;--------------------------------------------------------------------------;
-
- marker:
-
- DB 'MBBIOS load marker' ;
-
- marklen EQU $-marker
-
- ;==========================================================================;
- ; Our BIOS handler ;
- ;==========================================================================;
-
- INCLUDE MBBUSVC.ASM; ; Service handler
-
- ;==========================================================================;
- ; Timer interrupt handler ;
- ;==========================================================================;
-
- INCLUDE MBBTIMER.ASM; ; Service handler
-
- ;==========================================================================;
- ; Interrupt handlers ;
- ;==========================================================================;
-
- INCLUDE MBBINTER.ASM; ; Interrupt handler
-
- ;==========================================================================;
- ; Generalized subroutines ;
- ;==========================================================================;
-
- INCLUDE MBBSUBR.ASM; ; General service subroutines
-
- ;==========================================================================;
- ; DV code ;
- ;==========================================================================;
-
- INCLUDE DESQVIEW.ASM; ; The DV code
-
- ;==========================================================================;
- ; Buffer round up ;
- ;==========================================================================;
-
- huh:
- ORG huh+16
- buffer_start:
-
- ;==========================================================================;
- ; Main line to initialize. This is located in the first buffer and is, ;
- ; therefore destroyed after things start. ;
- ;==========================================================================;
-
- ASSUME DS: everything ; DS works here
- ASSUME ES: NOTHING ; Don't use ES
- ASSUME SS: NOTHING ; Don't use SS
-
- ;--------------------------------------------------------------------------;
- ; Variables only needed by initialization ;
- ;--------------------------------------------------------------------------;
-
- parm_flag DB 0 ; Input parameter
- parm_flag_f EQU 10000000B ; "F" -- Force load
- parm_flag_r EQU 01000000B ; "R"
- parm_flag_u EQU 00100000B ; "U" -- Unload
- parm_flag_d EQU 00010000B ; "D" -- Desqview
-
- psp_count DB 0 ; Number of PSP's after us...
-
- com_init_count DW 0 ; Number of ports done * 2
-
- need_tmr DB 0 ; Need to snatch timer
-
- ;--------------------------------------------------------------------------;
- ; Start the initialization code ;
- ;--------------------------------------------------------------------------;
-
- start:
-
- MOV AX,CS ; Point DS in the right place
- MOV DS,AX ;
-
- ;--------------------------------------------------------------------------;
- ; Announce our presence ;
- ;--------------------------------------------------------------------------;
-
- MOV DX,OFFSET msghello ; Message
- MOV AH,dos_write_line ; Send to output
- INT dos_vector_no ;
-
- ;--------------------------------------------------------------------------;
- ; Check loading status, etc ;
- ;--------------------------------------------------------------------------;
-
- INCLUDE MBBLOAD.ASM ;
-
- ;--------------------------------------------------------------------------;
- ; Create an hole in the routines here to prevent buffer clobber during ;
- ; init. There must be 16 bytes prior to the buffer end clear ;
- ;--------------------------------------------------------------------------;
-
- JMP init_section2 ;
-
- ORG buffer_start + buffer_size ;
-
- init_section2:
-
- ;--------------------------------------------------------------------------;
- ; Initialize buffers, etc ;
- ;--------------------------------------------------------------------------;
-
- INCLUDE MBBINIT.ASM ;
-
- ;--------------------------------------------------------------------------;
- ; This leaves a small hole in the code for the buffer pointer ;
- ;--------------------------------------------------------------------------;
-
- JMP over_pointer
- ORG $+100
- over_pointer:
-
- ;--------------------------------------------------------------------------;
- ; Tell everybody we worked! ;
- ;--------------------------------------------------------------------------;
-
- MOV DX,OFFSET msgok ; Message
- MOV AH,dos_write_line ; Send to output
- INT dos_vector_no ;
-
- ;--------------------------------------------------------------------------;
- ; Exit and stay resident ;
- ;--------------------------------------------------------------------------;
-
- MOV AL,buffer_count ; Calculate size of buffer space
- CBW ;
- MOV BX,buffer_size ; Calculate size of buffer space
- MUL BX ; needed.
-
- MOV DX,OFFSET buffer_start+5 ;note some slack...
- ADD DX,AX ; Total length!
-
- INT dos_tsr_no ; Terminate but stay resident
-
- ;--------------------------------------------------------------------------;
- ; Create an hole in the routines here to prevent buffer clobber during ;
- ; init. There must be 16 bytes prior to the buffer end clear ;
- ;--------------------------------------------------------------------------;
-
- ORG buffer_start + 3*buffer_size ;
-
- ;==========================================================================;
- ; Messages ;
- ;==========================================================================;
-
- msghello DB 'MBBIOS Version 3.5 -- October 7th, 1990',13,10
- DB '(c) 1987, 1988, 1989, 1990 H.R. Engehausen',13,10
- DB 'Freely copyable for non-commercial purposes',13,10,13,10,'$'
-
- msgbad DB 'Invalid input parameter',13,10,'$'
-
- msgok DB 'MBBIOS loaded and ready',13,10,'$'
-
- msgdupe DB 'MBBIOS already loaded -- Load ignored',13,10,'$'
-
- msgnodup DB 'MBBIOS not loaded -- Unload ignored',13,10,'$'
-
- msgnotlast DB 'Something in memory after MBBIOS -- Unload ignored',13,10,'$'
-
- msgunload DB 'MBBIOS successfully unloaded',13,10,'$'
-
- ;==========================================================================;
- ; Buffers ;
- ;==========================================================================;
-
- ; The buffers are here
-
- program_end:
-
- everything ENDS
-
- END dos_start